package redis

import (
	"hft/Database/admin"
	"hft/global"
	"strconv"
)

// 初始化电话号码

func InitPhone() {

	var newPhoneMax int

	res, err := global.OC_REDIS.Get("phone_max").Result()

	var phone int

	if err != nil {
		global.OC_DB.Model(&admin.SellLouPanInfo{}).Select("MAX(sell_phone)").Find(&phone)

		newPhoneMax = phone
	} else {

		var num, _ = strconv.Atoi(res)

		if num < 10000 {
			newPhoneMax = 10000
		} else {
			newPhoneMax = num
		}
	}

	global.OC_REDIS.Set("phone_max", newPhoneMax, 0)

}
